package fr.musique.service;

import java.util.ArrayList;
import java.util.List;

import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import fr.musique.bean.Playlist;
import fr.musique.itf.PlaylistItf;

@Service("playlistService")
@WebService(endpointInterface = "fr.musique.service.PlaylistService")
public class PlaylistServiceImpl implements PlaylistService {

	@Autowired
	protected PlaylistItf playlist;

	// Permet de récupérer un objet playlist en fonction de son id
	@Override
	@Transactional
	public Playlist get(int id) {
		return this.playlist.get(id);
	}

	// Permet de récupérer la liste des objets playlist
	@Override
	@Transactional
	public List<Playlist> getAll() {
		List<Playlist> resultats = new ArrayList<Playlist>();

		for (Playlist res : this.playlist.getAll()) {
			resultats.add(res);
		}

		return resultats;
	}

	// Permet de sauvegarder un objet playlist
	@Override
	@Transactional
	public void save(Playlist playlist) {
		this.playlist.save(playlist);
	}
}